import {httpDelete, httpGet, httpPageableGet, httpPost, httpPut} from '@/utils/request'


export async function findOne(id: any): Promise<any> {
  const {data, success} = await httpGet(`/api/v1/channel/findOne/${id}`)
  return {data, success};
}

export async function findByPipelineId(id: any): Promise<any> {
  const {data, success} = await httpGet(`/api/v1/channel/find-one-pipelineId/${id}`)
  return {data, success};
}

export async function list(params?: any): Promise<any> {
  const {data, total} = await httpPageableGet('/api/v1/channel/list', params)
  return {data, total};
}

export async function updateChannel( params?:any ) :Promise<any>{
  const { code }  = await httpPut('/api/v1/channel/edit',params)
  return code === 200;
}

export async function createChanel( params?:any ) :Promise<any>{
  const { code }  = await httpPost('/api/v1/channel/add',params)
  return code === 200;
}

export async function deleteById(id: any): Promise<any> {
  const {code} = await httpDelete(`/api/v1/channel/delete/${id}`)
  return code === 200;
}

/**
 * 运行状态的更新操作
 */
export async function status(id: any, status: any): Promise<any> {
  const {code} = await httpPost(`/api/v1/channel/status/${id}/${status}`)
  return code === 200;
}

/**
 * 推送
 */
export async function push(id: any): Promise<any> {
  const {code, msg} = await httpPost(`/api/v1/channel/push/${id}`)
  return code === 200;
}

